/*
 * @Descripttion: 
 * @version: xxx
 * @Author: fuchengguo
 * @Date: 2020-07-16 18:46:26
 * @LastEditors: fuchengguo
 * @LastEditTime: 2020-10-09 17:00:25
 */
import dialog from '@/common/utils/dialog.js'
const validator = {
	phone(phone) {
		if (!/^1[3456789]\d{9}$/.test(phone)) {
			return false
		}
		return true
	},
	toast(params, attention) {
		if (!params) {
			uni.showModal({
				title: '提示',
				content: `请输入${attention}`,
				showCancel: false
			})

			return false

		}
		return true
	},
	password(pwd) {
		return new Promise((resolve, reject) => {
			pwd = String(pwd)
			const reg = /^(?![^a-zA-Z]+$)(?!\D+$)/;
			if (pwd.length < 6 || pwd.length > 18) {
				dialog.toast('密码长度在6-18个字符之间')
				reject()
				return
			}
			if (!reg.test(pwd)) {
				dialog.toast('密码需要包含字母和数字')
				reject()
				return
			}
			resolve()
		})
	}
}
export default validator;